//
//  YWDetectAndUpkeepManager.h
//  maintain
//
//  Created by Kyo on 16/9/6.
//  Copyright © 2016年 ewin. All rights reserved.
//

#import <Foundation/Foundation.h>
//#import "YWSingleton.h"
#import "YWMission.h"

@class YWAssignMissionCount;
@class YWEquipmentMaintenanceRecord;

static NSString *const KRefreshPostAssignDetectAndUpkeepMissionNotification = @"KRefreshPostAssignDetectAndUpkeepMissionNotification";
static NSString *const KRefreshDeleteDetectAndUpkeepMissionNotification = @"KRefreshDeleteDetectAndUpkeepMissionNotification";

@interface YWDetectAndUpkeepManager : NSObject
//YWSingletonH(Manager)

/**
 *  保存任务信息
 *
 *  @param missions 任务模型数组
 *
 *  @return 结果
 */
+ (BOOL)updateDetectAndUpkeepMissionWithArray:(NSArray*)missions;
/**
 *  获取任务（检测、保养）
 *
 *  @param status 任务状态
 *  @param maintenanceType 任务类型
 *
 *  @return 任务模型数组
 */
+ (NSArray*)detectAndUpkeepMissionWithStatus:(YWMissionFinishStatus)status maintenanceType:(YWMaintenanceType)type page:(NSInteger)page;
/**
 *  获取任务（检测、保养）
 *
 *  @param missionId 任务Id
 *
 *  @return 任务模型
 */
+ (YWMaintenanceMission *)maintenanceMissionWithMissionId:(NSInteger)missionId;


/**
 *  更新维保记录（检测、保养）
 *
 *  @param maintenanceRecordJsons 维保记录Json模型数组
 *  @param maintenanceTypeId 维保类型
 *  @return 结果
 */
+ (BOOL)updateMaintenanceRecordJsons:(NSArray*)maintenanceRecordJsons maintenanceTypeId:(YWMaintenanceType)maintenanceTypeId;
/**
 *  保存维保记录（检测、保养）
 *
 *  @param maintenanceRecords 维保记录模型数组
 *  @param maintenanceTypeId 维保类型
 *  @return 结果
 */
+ (BOOL)updateMaintenanceRecords:(NSArray*)maintenanceRecords maintenanceTypeId:(YWMaintenanceType)maintenanceTypeId;

/**
 *  获取维保记录（检测、保养）
 *
 *  @param equipmentId 设备Id
 *  @param maintenanceTypeId 维保行为类型Id
 *  @param page 页数
 *
 *  @return 维保记录模型数组
 */
+ (NSArray*)maintenanceRecordArrayWithEquipmentId:(NSString*)equipmentId maintenanceTypeId:(YWMaintenanceType)maintenanceTypeId withPage:(NSInteger)page;
/**
 *  获取任务的维保记录（巡查、检测、保养）
 *
 *  @param mission 任务
 *  @param equipmentId 设备Id
 *
 *  @return 维保记录模型数组
 */
+ (YWEquipmentMaintenanceRecord*)maintenanceRecordWithMission:(YWMaintenanceMission*)mission equipmentId:(NSString*)equipmentId;
/**
 *  获取任务的记录 按位置id分组
 *
 *  @param mission 任务
 *
 *  @return 字典    locaionId : NSArray<YWEquipmentMaintenanceRecord>
 */
+ (NSDictionary*)detectAndUpkeepRecordsWithMission:(YWMaintenanceMission*)mission;

/**
 *  维保任务循环周期
 *
 *  @param missionCycle 循环周期
 *
 *  @return 无
 */
+ (NSString *)missionCycleStringWithCycle:(NSInteger)missionCycle;

/**
 *  请求维保任务
 *
 *  @return 无
 */
+ (void)requestDetectAndUpKeepMissionWithUrl:(NSString*)url page:(NSInteger)page pageSize:(NSInteger)pageSize status:(NSInteger)status completeBlock:(void (^)(NSInteger))complete;
/**
 *  请求单个维保任务
 *
 *  @return 无
 */
+ (void)requestMissionWithMissionId:(NSInteger)missionId completeBlock:(void (^)(YWMaintenanceMission*mission))complete;
/**
 *  请求任务的维保记录
 *
 *  @return 无
 */
+ (void)requestMissionRecordWithMission:(YWMaintenanceMission*)mission completeBlock:(void (^)(NSInteger))complete;


/**
 *  查询设备类型总数和已完成数
 *
 *  @param params 提交的参数
 *
 *  @return 无
 */
+ (void)requestAssignMissionCountWithBuildingId:(NSString*)buildingId equipmentTypeId:(NSInteger)equipmentTypeId maintenanceTypeId:(NSInteger)maintenanceTypeId WithComplete:(void(^)(YWAssignMissionCount* assignMissionCount))complete;

/**
 *  分配检测保养任务
 *
 *  @param params 提交的参数
 *
 *  @return 无
 */
+ (void)assiginDetectAndUpkeepMission:(NSDictionary*)params WithComplete:(void(^)(BOOL success))complete;

/**
 *  删除检测,保养任务的请求
 *
 *  @param missionId 任务id
 *  @param typeId    任务类型
 *
 *  @return 无
 */
+ (void)requestDeleteMission:(NSInteger)missionId maintenanceType:(NSInteger)typeId completeBlock:(void (^)(BOOL))complete;
/**
 *  修改检测保养任务
 *
 *  @param params 提交的参数
 *
 *  @return 无
 */
+ (void)requestModifyDetectAndUpkeepMission:(NSDictionary*)params complete:(void(^)(BOOL success))complete;
/**
 *  所有检测保养任务的ID串
 *
 *  @return 无
 */
+ (NSString*)allUnfinishDetectAndUpkeepMissionIds;
/**
 *  更新检测保养任务的数据状态
 *
 *  @return 无
 */
+ (void)updateDetectAndUpkeepMissionStatus;

/**
 *  请求设备的检测保养记录
 *
 *  @return 无
 */
+ (void)requestEquipmentDetectAndUpkeepRecordWithMaintenanceTypeId:(NSInteger)maintenanceTypeId equipmentIds:(NSString*)equipmentIds page:(NSInteger)page pageSize:(NSInteger)pageSize completeBlock:(void (^)(NSInteger))complete;

/**
 *  开始上传检测保养记录
 *  @param records        记录模型数组
 *  @param mission        任务模型
 *  @param pictures       记录中所有的图片
 */
- (void)startUploadDetectAndUpkeepRecords:(NSArray*)records maintenanceMission:(YWMaintenanceMission*)maintenanceMission pictures:(NSArray*)pictures;
/**
 *  上传失败的检测保养记录
 *
 *  @return 无
 */
- (void)uploadFailedDetectAndUpkeepRecords;

@end
